a = list(input())
s = []
d = True

for i in a:
    if i in "([{<":
        s.append(i)
    elif i in ")]}>":
        if len(s) == 0:
            d = False
            break
        if (s[-1] == "(" and i == ")") or (s[-1] == "[" and i == "]") or (s[-1] == "{" and i == "}") or (s[-1] == "<" and i == ">"):
            s.pop()
        else:
            d = False
            break

if d and len(s) == 0:
    print("True")
else:
    print("False")
